<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>do-while</title>
</head>
<body>
  <button onclick="funDo()">跑二十圈</button>
    <button onclick="funAdd100()">计算1到100之间所有整数累加之和</button>
    <button onclick="funAddEven()">计算1到100之间所有偶数累加之和</button>
    <button onclick="funContinue()">循环跳过周三</button>
    <button onclick="funBreak()">跳出循环</button>
</body>
<script>

    function funBreak(){
        var i = 1
        do{
            if(i == 3){
                break;
            }
            console.log("周" + i +"刷碗")
            i++
        }while(i<=7)
    }

    function funContinue(){
         var i = 1
        do{
            if(i == 3){
                i++
                continue
            }
            console.log("周" + i +"刷碗")
            i++
        }while(i<=7)
    }


  function funAddEven() {
      var i = 1
      sum = 0
      do{
          if(i%2 == 0){
              sum += i
          }
          i++
      }while(i<=100)
      console.log(sum)
  }


  function funAdd100() {
      var  i = 1
      var sum = 0
      do{
          sum += i
          i++
      }while(i<=100)

      console.log(sum)
  }

  function funDo(){
      var i = 1
      do{
          console.log("跑了" + i +  "圈")
          i++
      }while(i<=20)
  }
</script>
</html>